require 'base64'

class LoginForm < FXMainWindow
  def initialize(anApp,sTitle)
    super(anApp, sTitle,:opts => DECOR_ALL, :width => 165, :height => 250)

    FXLabel.new(self,"Username:", nil, JUSTIFY_LEFT|LAYOUT_FILL_X)
    txtUsername = FXTextField.new(self, 26, nil, 0, TEXTFIELD_NORMAL)
	txtUsername.text = "UOD_Assignment"

    FXLabel.new(self,"Password:", nil, JUSTIFY_LEFT|LAYOUT_FILL_X)
    txtPassword = FXTextField.new(self, 26, nil, 0, TEXTFIELD_NORMAL|TEXTFIELD_PASSWD)
	txtPassword.text = "assignment123"

    xbButton = FXButton.new(self,"Log in",:opts => FRAME_RAISED|LAYOUT_CENTER_X|LAYOUT_FIX_WIDTH|LAYOUT_FIX_HEIGHT,:width => 80, :height => 20)
    xbButton.connect(SEL_COMMAND){
		if(txtUsername.text != ""  && txtPassword.text != "")
			@@sAuthString = Base64::encode64(txtUsername.text+':'+txtPassword.text)
			close
		end
	}
    end
  
  def create
    super
    show(PLACEMENT_SCREEN)
  end
end